package com.duanjw.springboot.echarts;

import org.springframework.messaging.Message;
import org.springframework.messaging.handler.annotation.MessageMapping;
import org.springframework.messaging.handler.annotation.SendTo;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.multipart.MultipartFile;

import java.util.HashMap;
import java.util.Map;

@Controller
public class TestController {
    public void upload(MultipartFile file){

    }

    @GetMapping()
    @ResponseBody
    public Map update(@PathVariable String value){
        Map<String,String> map = new HashMap(8);
        map.put("v", value);
        return map;

    }

    @MessageMapping("hello")
    @SendTo("/topic/echarts")
    public String ws(Message message){
        byte[] bytes = (byte[])message.getPayload();
        String s = new String(bytes);
        System.out.println(s);
        return "100";
    }
}
